package com.lagou.homework.Modules1;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class SortMapper extends Mapper<LongWritable, Text, LongWritable, NullWritable> {

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        //传入三个文件的参数
        //获取一行
        String line = value.toString();
        //切割
        String[] words = line.split("\n");

        //Text k = new Text();
        //IntWritable k = new IntWritable();
        LongWritable k = new LongWritable();
        //输出
        for (String word : words) {
            k.set(Long.parseLong(word));
            context.write(k, NullWritable.get());
        }
    }
}
